 /**-----------------云台控制---------------
	* 
	
 不区分大小写
 说明：
 LEFT 左转
 RIGHT右转
 UP 上转
 DOWN 下转
 ZOOM_IN 焦距变大
 ZOOM_OUT 焦距变小
 LEFT_UP 左上
 LEFT_DOWN 左下
 RIGHT_UP 右上
 RIGHT_DOWN 右下 FOCUS_NEAR 焦点前移
 FOCUS_FAR 焦点后移 IRIS_ENLARGE 光圈扩大
 IRIS_REDUCE 光圈缩小
 WIPER_SWITCH 接通雨刷开关
 START_RECORD_TRACK开始记录轨迹
 STOP_RECORD_TRACK 停止记录轨迹
 START_TRACK 开始轨迹
 STOP_TRACK 停止轨迹
 
 以下命令presetIndex不可
 为空：
 GOTO_PRESET到预置点
*/
 const eCtrlType = {
 	UP: "UP", //上转
 	LEFT: "LEFT", // 左转
 	LEFT_UP: "LEFT_UP", // 左上
 	LEFT_DOWN: "LEFT_DOWN", //左下
 	DOWN: "DOWN", // 下转
 	RIGHT: "RIGHT", //右转
 	RIGHT_UP: "RIGHT_UP", // 右上
 	ZOOM_IN: "ZOOM_IN", // 焦距变大
 	ZOOM_OUT: "ZOOM_OUT", // 焦距变小
 	RIGHT_DOWN: "RIGHT_DOWN", //右下
 	/**
	 FOCUS_NEAR,// 焦点前移
 	"FOCUS_FAR", // 焦点后移 
	IRIS_ENLARGE,// 光圈扩大
 	"IRIS_REDUCE", // 光圈缩小
 	WIPER_SWITCH, // 接通雨刷开关
 	START_RECORD_TRACK, //开始记录轨迹
 	STOP_RECORD_TRACK, // 停止记录轨迹
 	START_TRACK, // 开始轨迹
 	STOP_TRACK, // 停止轨迹
	GOTO_RESET,//转到预置点*/
 };
 //export default eCtrlType;

 ;
 class CtrlCam {
 	api;
 	constructor() {

 	}

 	dat = [{
 			name: "放大",
 			cls: 'vb v-out',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.ZOOM_IN)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.ZOOM_IN)
 			}
 		}, {
 			name: "缩小",
 			cls: 'vb v-in',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.ZOOM_OUT)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.ZOOM_OUT)
 			},
 		},
 		{
 			name: "上",
 			cls: 'vb v-dir v-up',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.UP)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.UP)
 			},
 		}, {
 			name: "下",
 			cls: 'vb v-dir v-down',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.DOWN)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.DOWN)
 			},
 		}, {
 			name: "左",
 			cls: 'vb v-dir v-left',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.LEFT)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.LEFT)
 			},
 		}, {
 			name: "右",
 			cls: 'vb v-dir v-right',
 			hB: (code) => {
 				this.hBegin(code, eCtrlType.RIGHT)
 			},
 			hE: (code) => {
 				this.hEnd(code, eCtrlType.RIGHT)
 			},
 		},
 	];
 	hSetApi(api) {
 		this.api = api;
 	}
 	hDo(cam) {
 		let url = `/GetHIKCam.ashx?title=Ptzs&${cam}`;
 		console.log("云台控制", url);
 		this.api.hGet(url, "", d => {
 			console.log("云台控制 返回", d);
 		});
 	}
 	hBegin(code, tp) {
 		//"presetIndex": 20 //预置点编号通常300以内
 		this.hDo(`code=${code}&action=0&command=${tp}&speed=50`);
 	}

 	hEnd(code, tp) {
 		let data = {
 			"cameraIndexCode": code,
 			"action": 1, //0开始，1停止
 			"command": tp,
 			"speed": 50, //速度1-100，默认50
 		};
 		this.hDo(`code=${code}&action=1&command=${tp}&speed=50`);
 		//	console.log("云台控制", p);
 		//"presetIndex": 20 //预置点编号通常300以内

 	}
 };
 export {
 	eCtrlType,
 	CtrlCam
 };